var level = [
  { id: 0, name: "初级" },
  { id: 1, name: "中级" },
  { id: 2, name: "高级" },
  { id: 3, name: "大师级" },
   { id: 4, name: "bt模式" }
];

function init() {
  var html = "";
  level.forEach(function(item) {
    console.log(item.name);
    html += `<div class='grade'>${item.name}</div>`;
    $(".level").html(html);
  });
}
init();

$(".level").on("click", ".grade", function(e) {
  console.log($(this).index());
  var lv = $(this).index() + 1;
  if (lv <= 4) {
    location.href = `./game.html?lv=${lv}`;
  }
  else if (lv > 4) { 
    location.href = `./bt.html`;
  }
 
});
